package ru.hh.team02.chat.messaging;

import ru.hh.team02.chat.server.Services;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class AsyncPrivateMessage implements Message {
    private final String text;
    private FutureTask<Integer> id;

    public String getText() {
        try {
            return " " + id.get() + " " + text;
        } catch (InterruptedException e) {
            Services.ADMIN_LOGGER.write("this should never happen");
        } catch (ExecutionException e) {
            Services.ADMIN_LOGGER.write("this should never happen");
        }
        return "server> oops";
    }

    public AsyncPrivateMessage(String text, FutureTask<Integer> id) {
        this.text = text;
        this.id = id;
    }
}